package everyday;

import java.util.HashSet;
import java.util.Set;

public class T2367 {
    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set=new HashSet<Integer>();
        int sum=0;
        for(int num:nums){
            set.add(num);
            if (set.contains(num-diff)&&set.contains(num-diff*2)){
                ++sum;
            }
        }
        return sum;
    }
}
